//
//  SDAlertController.m
//  skinDetection
//
//  Created by  liangzhun on 2018/10/31.
//  Copyright © 2018年  liangzhun. All rights reserved.
//

#import "SDAlertController.h"
#import "SDDetectionViewController.h"
@interface SDAlertController ()

@end

@implementation SDAlertController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.alertView.layer.masksToBounds = self.cancelBtn.layer.masksToBounds = self.confirmBtn.layer.masksToBounds = YES;
    self.alertView.layer.cornerRadius = self.cancelBtn.layer.cornerRadius = self.confirmBtn.layer.cornerRadius = 5.0;
    self.cancelBtn.layer.borderColor =  SDMainColor.CGColor;
    self.cancelBtn.layer.borderWidth =  1.f;
    [self.cancelBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
        [self dismissView];
    }];

    [self presentView];
    
    
}
- (void)setAlertContent:(NSString *)content Title:(NSString *)title CancelTitle:(NSString *)cancalTitle ConfirmTitle:(NSString *)confirmTitle
{
    [self.alertTitleLab setText:title];
    [self.contentLab setText:content];
    [self.cancelBtn setTitle:cancalTitle forState:UIControlStateNormal];
    [self.confirmBtn setTitle:confirmTitle forState:UIControlStateNormal];
    
}
- (void)presentView
{
    self.alertView.alpha = 0.2;
    [UIView animateWithDuration:0.1 animations:^{
        self.alertView.alpha = 1.0;
    } completion:^(BOOL finished) {
        
    }];
}
- (void)dismissView
{

    [UIView animateWithDuration:0.2 animations:^{
        self.alertView.alpha = 0.1;
    } completion:^(BOOL finished) {
        [self.view removeFromSuperview];
        [self removeFromParentViewController];
    }];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
   
    if (touch.view == self.alertView) {
        return;
    }
    [self dismissView];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
